
Imports std
Imports System.IO

Module excludeW

    Sub Main(ByVal args() As String)
        On Error Resume Next

        If isdebugmode() Then
            pause()
        End If
        If args.Length < 2 Then
            raiseError("argument count error, input output excludeString0 excludeString1 ... excludeStringN, " + _
                        "if input or output is /-, use console, program will transform backslashes", _
                        errorHandle.errorType.critical)
        Else
            Dim writer As TextWriter = Nothing
            Dim tempfile As String = Nothing
            Dim i As Int32

            registerConsoleExtHandle()

            tempfile = createGUID()
            writer = New StreamWriter(New FileStream(tempfile, FileMode.Create, FileAccess.Write, FileShare.Read))
            For i = 2 To args.Length() - 1
                unescape(args(i))
                writer.WriteLine(args(i))
            Next
            closestream(writer)

            Dim cmd As String = "excludewf " + ShellExDefault.infileIdentify + character.blank _
                                 + ShellExDefault.outfileIdentify + character.blank + tempfile
            ShellEx(cmd, args(0), args(1), , , , AppWinStyle.Hide, True)
            'Dim cmd As String = "excludewf " + args(0) + character.blank _
            '                     + args(1) + character.blank + tempfile
            'Shell(cmd, AppWinStyle.Hide, True)

            File.Delete(tempfile)

            consoleExtHandleFinish()
        End If
    End Sub

End Module
